home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / drivers / xgav210.zip / XGAPCDOS / CALLAFI.ASM < prev    next >
Assembly Source File  |  1993-07-21  |  5KB  |  160 lines

  1. ;
  2. ; (C) Copyright IBM Corporation 1986,1987,1988,1989,1990
  3. ;
  4. ;
  5. ;
  6. ; Assembler 'glue' allowing IBM 'C' compiled code to communicate with
  7. ; the Adapter Interface in PCDOS mode.
  8. ;
  9. ;
  10. ;
  11. ;
  12. ;
  13.         page 80,132
  14. ;
  15. ; Call Adapter Interface, Get Adapter Interface address vector & Get Adapter
  16. ; interface linked list address
  17. ; (_CALLAFI , _GETAFI & _GETAFIL)
  18. ;
  19. DGROUP  group   _DATA
  20. ;
  21. _DATA   segment word public 'DATA'
  22.         assume  ds:DGROUP,cs:_text
  23. ;
  24. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  25. ;
  26. ; Global pointer to Adapter Interface entry point address list
  27. ; declared as: extern char far *afi_ptr;
  28. ;
  29.         public  _afi_ptr       ; Adapter Interface entry table block address
  30. ;
  31. _afi_ptr dd    0               ;
  32.          db    '(C) Copyright IBM Corporation 1986,1987,1988,1989'
  33. _DATA   ends
  34. ;
  35. _TEXT   segment byte public 'CODE'
  36.         public  _callafi,_getafi,_getafil
  37. ;
  38. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  39. ;
  40. ;  Call Adapter Interface - CALLAFI
  41. ;
  42. ;  This subroutine is assembler glue, to allow IBM 'C' compiled code
  43. ;  to call the Adapter Interface.
  44. ;
  45. ;  declared as shown:
  46. ; extern void far callafi(int,char far *);
  47. ;
  48. ;
  49. ;
  50. _callafi proc   far             ; far entry point
  51.         push    bp
  52.         mov     bp,sp
  53.         push    di              ; save register variables
  54.         push    si              ; save register variables
  55. ;
  56.         mov     ax,[bp+6]       ; entry no. to ax
  57. ;
  58.         les     bx,[bp+8]       ; parm block address
  59.         push    es              ; onto stack
  60.         push    bx              ;     offset too
  61. ;
  62.         shl     ax,1            ; form offset from entry no. required
  63.         shl     ax,1            ;
  64.         mov     si,ax           ;
  65. ;
  66.         les     bx,_afi_ptr    ; entry block address to es:bx
  67.         call    dword ptr es:[bx][si]    ; call entry point
  68. ;
  69.         pop     si              ; restore register variables
  70.         pop     di              ; restore register variables
  71.         pop     bp              ; restore bp
  72.         ret                     ; return to caller
  73. ;
  74. _callafi endp
  75. ;
  76. ;
  77. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  78. ;
  79. ;  Get Adapter Interface address vector - _GETAFI
  80. ;
  81. ;  This subroutine is assembler glue, to allow IBM 'C' compiled code
  82. ;  to acquire the Adapter Interface entry point address list.
  83. ;
  84. ;  declared as shown:
  85. ; extern char far *(far getafi(void));
  86. ;
  87. ;
  88. _getafi proc   far              ; far entry point to fetch
  89.         push    bp
  90.         mov     bp,sp
  91.         push    di              ; save register variables
  92.         push    si              ; save register variables
  93. ;
  94.         mov     ax,357fh        ; read interrupt vector 7f
  95.         int     21h             ; by function call
  96.         mov     ax,es           ; es to ax
  97.         or      ax,bx           ; is 7f vector null
  98.         jz      return          ;
  99. ;
  100.         mov     ax,0105h        ; get Interface address
  101.         int     7fh             ; by software interrupt 7f
  102. ;
  103.         jc      return          ; Interface not OK if carry set
  104. ;
  105.         mov     word ptr _afi_ptr,dx  ; save afi pointer offset
  106.         mov     word ptr _afi_ptr+2,cx  ; save afi pointer segment
  107. ;
  108. return:
  109. ;
  110.         mov     ax,word ptr _afi_ptr  ; return ptr in dx:ax
  111.         mov     dx,word ptr _afi_ptr+2  ; return ptr in dx:ax
  112. ;
  113.         cld                     ; clear direction flag
  114.         clc                     ; clear carry flag
  115.         pop     si              ; restore register variables
  116.         pop     di              ; restore register variables
  117.         pop     bp              ; restore bp
  118.         ret                     ; return to caller
  119. ;
  120. _getafi endp
  121. ;
  122. ;
  123. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  124. ;
  125. ;  Get Adapter Interface Linked List address vector - _GETAFIL
  126. ;
  127. ;  This subroutine is assembler glue, to allow 'C' to
  128. ;  acquire the Adapter Interface entry point address list.
  129. ;
  130. ;  declared as shown:
  131. ; extern struct afi_list_entry far *(far getafil(void));
  132. ;
  133. ;
  134. _getafil proc   far             ;far entry point to fetch
  135.                                 ;
  136.         mov     ax,357Fh        ;read interrupt vector 7f
  137.         int     21h             ;by function call
  138.         mov     ax,es           ;es to ax
  139.         or      ax,bx           ;is 7f vector null
  140.         jz      llerror         ;IF  INT 7F vector <> NULL
  141.         mov     ax,0113h        ;    Get Interface Linked List address into
  142.         xor     bx,bx           ;    CX:DX by software interrupt 7f(ax=113,bx=0)
  143.         int     7Fh             ;
  144.                                 ;AND Linked List address returned OK
  145.         jc      llerror         ;
  146.         mov     ax,dx           ;   Put Linked list address dx:ax
  147.         mov     dx,cx           ;   which is this functions returned ptr value
  148.         jmp     short llend     ;
  149. llerror:                        ;ELSE
  150.         xor     ax,ax           ;   Set return ptr in dx:ax
  151.         xor     dx,dx           ;   to NULL
  152. llend:                          ;END IF
  153.         cld                     ; clear direction flag
  154.         ret                     ; return to caller
  155. ;
  156. _getafil endp
  157. ;
  158. _TEXT   ends
  159.         end
  160.